This folder contains an OS (Operating system) written in both C and assembly.
To use it, try to run the command "make run". It may ask you to install a few things, do so.

----------------------------------------------------------------

The main features of this OS, by chronological order of addition:

1. Boot - Most of it in boot.s, hands out to kernel.c.
We use the multiboot specification.
Then define a 32KB stack which is the stack we will use for C which needs a stack. esp points to its top.
The multiboot info is recovered from the register ebx, and passed as argument to the main C function.

2. Terminal - Most of it in vga.c.
We use the VGA text buffer at 0xB8000. Define fuctions to print strings and numbers.
Also some cosmetic stuff like scrolling, clearing the screen etc.

3. Linker script - In linker.ld.
This file "links" all the .o binaries output by the compiler into one big executable binary.
We need to overwrite the default one because we want to control were all the instructions will be written in memory.

4. Global Descriptor Table - In gdt.c.
This defines segmentation of the memory into segments. Essentially default, does not really do anything.

5. Interrupt Descriptor Table - In idt.c.
This is what allows the kernel code to be interrupted (by a keystroke, an error, or timer ticks).
It's a big table with 256 entries, and each entry says "when interrupt N fires, jump to this address".

6. Programmable Interrupt Controller - In pic.c.
It solves the problem that the CPU has only one interrupt pin while we want many types of interrupt through keyboards and other devices.
It solves it in the following way: it has many interrupt pins, and each pin sends an interrupt with a different report for each.
Problem: pins are mapped to reports already taken by other (non hardware) types of interrupts. So we remap them.
Also after every interrupt we have to let the PIC know we're done so that it can fire again.

7. Interrupt handers - In interrupt.s and idt.c.
We tell the program what to do after an interrupt raised by the PIC.
It includes timer interrupts and keyboard strokes.

8. Keyboard driver - In keyboard.c.
This is what it sounds like: all the functions needed to grab character and commands written by the user.
Then we can use these in the shell to register user commands.

9. String library - In string.c.
Just a standard string library, which does not exist in default C.
It is essentially used to compare strings, so that we can register commands in the shell.

10. Shell - In shell.c.
This is the system of commands.
Essentially a big if/else loop, with one case for each command, and what to do for each command.

11. Timer - In timer.c.
This is just a timer. There is one , very fast, built into the hardware.
We just count ticks to get a 100Hz virtual clock instead.
We also have functions there to lookup the time elapsed.

12. Bump allocator - In kmalloc.c.
This system is to allocate memory to potential future programs.
It works by noting first the start and end of available memory, and then moving a cursor every time memory is asked for.
It precedes the more complex page handling for memory.

13. Paging - In paging.c.
We define a notion of virtual address and create a mapping between virtual addresses and hardware real addresses.
They are translated by pages of 4KB, each lying in a larger directory.
The issue is: the moment we enable paging, all addresses become virtual, including the address of the next instruction.
So we need the mapping to be the identity on the beginning (where the kernel code lives).
